const { DataTypes } = require("sequelize");
const sequelize = require("../db/sequelize");

const User = sequelize.define(
  "user",
  {
    username: {
      type: DataTypes.STRING,
      allowNull: false,
      unique: true,
    },
    password: {
      type: DataTypes.STRING,
      allowNull: false,
    },
    phone: {
      type: DataTypes.STRING,
    },
    portrait: {
      type: DataTypes.STRING,
    },
    gender: {
      type: DataTypes.STRING,
    },
    age: {
      type: DataTypes.TINYINT,
    },
    isAdmin: {
      type: DataTypes.BOOLEAN,
      defaultValue: 0,
    },
    remark: DataTypes.STRING,
    createTime: DataTypes.DATE,
    updateTime: DataTypes.DATE,
  },
  {
    timestamps: true,
    createdAt: "createTime",
    updatedAt: "updateTime",
  }
);

module.exports = User;
User.sync({ force: true });
